import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions


class TestWait():
    def setup(self):
        self.driver = webdriver.Chrome()
        self.driver.maximize_window()
        self.driver.implicitly_wait(5) #隐式等待

    def testwait_show(self):
        self.driver.get('https://testerhome.com/')
        self.driver.find_element(By.LINK_TEXT,'社团').click()
        time.sleep(3)      #直接等待
        '''#强制等待方法，until里面传递的是条件
        def wait1(x):
            return len(self.driver.find_elements(By.CLASS_NAME,'team-name')) >=1
        WebDriverWait(self.driver,10).until(wait1)'''
        #until里面传递的条件元素可被点击
        WebDriverWait(self.driver,4).until(expected_conditions.element_to_be_clickable())
        self.driver.find_element(By.CLASS_NAME,'team-name').click()
        print('hello')